<?php
/**
 * fk模块微站定义
 *
 * @author zh
 * @url http://bbs.012wz.com/
 */
defined('IN_IA') or exit('Access Denied');

class Zh_qyfkModuleSite extends WeModuleSite {

	public function doWebList() {                  //反馈列表
		//这个操作被定义用来呈现 管理中心导航菜单
		global $_W,$_GPC;
		require 'fans.web.php';

		//$user = pdo_fetch("SELECT * FROM ".tablename('zh_qyfk_fl')."  ");
		
		include $this->template('list');

		// if (!empty($member['xh'])) {
		// 	$xuehao = $member['xh'];
		// }else{
		// 	$xuehao = $member['gh'];
		// }
	
	
				
		// $qx = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id = '{$xuehao}' ");

		// if ($qx > 0) {

		// 	$department_id = pdo_fetch("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id = '{$xuehao}' ");
		// 	$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';

		// 	if ($department_id['department_id'] == 1){             //权益部权限 超级管理员级别 可以看到所有部门反馈的问题

		// 	if($operation == 'display'){
		// 	$list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_upfile')." AS tp where xx.category_id=fl.id ");
		// 	    foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];
		// 	    }

		// 	    $total = count($list);  
  //               $pageindex = max($_GPC['page'], 1 );  
  //               $pagesize = 10;  
  //               $pager = pagination($total, $pageindex, $pagesize);  
  //               $p = ($pageindex-1) * 10;  
  //               $list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_upfile')." AS tp where xx.category_id=fl.id LIMIT " . $p . "," . $pagesize);
  //               foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];
		// 	    }

		//      }

		// 	}
		// 	else{                                                    //其它部门权限 管理员权限 仅可以看到自己部门的反馈的问题
		// 		if($operation == 'display'){
		// 	   $list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_bm')." AS bm where xx.category_id=fl.id and xx.category_id=bm.id and bm.id='{$department_id['department_id']}' ");
		// 	      foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];
		// 	    }

		// 	    $total = count($list);  
  //               $pageindex = max($_GPC['page'], 1 );  
  //               $pagesize = 10;  
  //               $pager = pagination($total, $pageindex, $pagesize);  
  //               $p = ($pageindex-1) * 10;  
  //               $list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_bm')." AS bm where xx.category_id=fl.id and xx.category_id=bm.id and bm.id='{$department_id['department_id']}' LIMIT " . $p . "," . $pagesize);
  //               foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];

		//      }
				 		
		// 	}

		// }
			          
  //   	if($operation == 'del'){
    		
  //   		$result = pdo_delete('zh_qyfk_xx', array('id' => $_GPC['xx_id']));
		// 		if (!empty($result)) {
		// 		message('删除成功');
		// 	}
			
  //   	}

  //   	if($operation == 'reply'){
  //   		$id = $_GPC['xx_id'];

  //   		$re = pdo_fetch("SELECT * FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_reply')." AS re where re.id='{$_GPC['xx_id']}' ");
  //   		if(empty($re)){
  //   			$m = pdo_fetch("SELECT * FROM ".tablename('zh_qyfk_xx')." AS xx where xx.id='{$_GPC['xx_id']}'");
  //   		}

  //   		if (checksubmit('submit')) {
		// 		$data = array(
		// 			'f_id' => $id,
		// 			'reply' => $_GPC['reply'],
		// 			'date'=>date("Y-m-d H:i:s")
		// 		); 

		// 		$status = array(
		// 			'status' => '已审核'
		// 		);
				
		// 			$result = pdo_insert('zh_qyfk_reply',$data);
		// 			$l = pdo_update('zh_qyfk_xx',$status,array('id' => $id));
		// 			if(!empty($result) && !empty($l)){
		// 				message('回复成功！');
		// 			}
		// 			else{
		// 				message('回复失败');
		// 			}				
		// 	}   		

  //   	} 

		// if($operation == 'search'){
		// 	$found = $_GPC['found'];
		// 	$department_id = $_GPC['departmentid'];
			
		// 	if($department_id == 1){
		// 	$li = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl  where (xx.category_id=fl.id and xx.f_name='{$found}' ) or (xx.category_id=fl.id and xx.f_studentid='{$found}') ");
		// 	foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];
		// 	    }

		// 	}else{
		// 		$li = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.studentid,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_bm')." AS bm where (xx.category_id=fl.id and xx.category_id=bm.id and bm.id='{$department_id}' and xx.f_name='{$found}') or (xx.category_id=fl.id and xx.category_id=bm.id and bm.id='{$department_id}' and xx.f_studentid='{$found}') ");
		// 	      foreach ($list as $k => $v) {
		// 		$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
		// 		$list[$k]['url']=$url['url'];
		// 	    }
		// 	}		
			
		// }

		// }
		
    	   	
		include $this->template('list');
	}

	//public function doMobileQuestion(){          //问题选项页面
	//	global $_W,$_GPC;
// 		echo 1;
// 		require 'fans.mobile.php';

		 
// 		$myqx = pdo_fetchAll("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.openid = '{$openid}' ");
// foreach ($myqx as $key => $value) {
// 	if($value['department_id']==1){
// 		$isadmin=1;
// 	}
// 	$qxdeptarr[]=$value['department_id'];
// }
 
// if(empty($qxdeptarr)){
// 	$deptwhere=" and 1=-1";
// }elseif($isadmin!=='1'){
// 	$qxstr=substing(explode (',',$qxdeptarr),-1);
// 	$deptwhere="and bm.id in(".$qxstr.")";
// }
//         	echo deptwhere;exit;


		 
// 			$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
// 			$department_id = pdo_fetchAll("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id = '{$xuehao}' ");

// 			if($department_id['department_id'] == 1){                     //权益部权限  超级管理员
// 				if($operation == 'display'){
// 		        $question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE fl.id=wt.category_id and bm.id=fl.department_id ".$deptwhere);

// 		        $total = count($question);  
//                 $pageindex = max($_GPC['page'], 1 );  
//                 $pagesize = 10;  
//                 $pager = pagination($total, $pageindex, $pagesize);  
//                 $p = ($pageindex-1) * 10;  
//                 $question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE( fl.id=wt.category_id and bm.id=fl.department_id) LIMIT " . $p . "," . $pagesize);


//               }

// 			}else{                                                      //其它部门权限  普通管理员权限
// 				if($operation == 'display'){                       
// 		        $question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_qx')." as qx  WHERE( fl.id=wt.category_id and bm.id=fl.department_id and bm.id=qx.department_id and bm.id='{$department_id['department_id']}') ");

// 		        $total = count($question);  
//                 $pageindex = max($_GPC['page'], 1 );  
//                 $pagesize = 10;  
//                 $pager = pagination($total, $pageindex, $pagesize);  
//                 $p = ($pageindex-1) * 10;  
//                 $question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_qx')." as qx  WHERE( fl.id=wt.category_id and bm.id=fl.department_id and bm.id=qx.department_id and bm.id='{$department_id['department_id']}') LIMIT " . $p . "," . $pagesize);
//               }

// 			}


		


//         if($operation == 'add'){
//         	$id = intval($_GPC['wt_id']);
// 			if (checksubmit('submit')) {
// 				$data = array(
// 					'department' => '1',
// 					'category' => '2',
// 					'question' => $_GPC['question'],
// 					'date'=>date("Y-m-d H:i:s")
// 				); 
				
// 					$result = pdo_insert('zh_qyfk_wt',$data);
// 					if(!empty($result)){
// 						message('添加成功！');
// 					}
// 					else{
// 						message('添加失败');
// 					}				
// 			}
		
//         }

//         if($operation == 'change'){
//         	// if($department_id['department_id'] == 1){
//         	// 	$id = $_GPC['id'];

//         	// 	$change = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_wt')." as wt where bm.id=fl.department_id and fl.id=wt.category_id and wt.id='{$_GPC['wt_id']}' "); 
//         	// 	$department = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_bm')." ");

//         	// 	echo "<pre>";
//         	// 	print_r($change);
//         	// 	echo "</pre>";

//         	// }else{

//         		$id = $_GPC['id'];
//         	$question = pdo_fetch("SELECT * FROM ".tablename('zh_qyfk_wt')." as wt where wt.id='{$_GPC['wt_id']}' ");

//         	$department_id = pdo_fetch("SELECT fl.department_id FROM ".tablename('zh_qyfk_wt')." as wt,".tablename('zh_qyfk_fl')." as fl where fl.id=wt.category_id and wt.id='{$_GPC['wt_id']}' ");

//         	$category = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_fl')." as fl where fl.department_id='{$department_id['department_id']}' ");

// //1.当前登录者的部门id
//         	//openid--mydeptid
//         	//$department_id
//         	//$deptwhere='';

//         	$department = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.id,bm.department FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE ( fl.id=wt.category_id and bm.id=fl.department_id) and wt.id='{$_GPC['wt_id']}' ".$deptwhere);
//         	// }
        	

//         	echo "<pre>";
        	

//         	echo "</pre>";

        	
// 			if(checksubmit('submit')){
// 				$data = array(
// 					'uid' => '1',
// 					'uniacid' => '2',
// 				    'category_id' => $_GPC['category_id'],
// 				    'question' => $_GPC['question'],
// 				    'date'=>date("Y-m-d H:i:s")
				    
// 				);
// 				if(!empty($id) && $id>0){
// 					$result = pdo_update('zh_qyfk_wt',$data,array('id'=>$id));
// 					if(!empty($result)){
// 						message('更新成功');
// 					}
// 					else{
// 						message('更新失败');
// 					}

// 					}
// 				}
				   	
//         }

//         if($operation == 'del'){
//         	$result = pdo_delete('zh_qyfk_wt',array('id' => $_GPC['wt_id']));
//         	if(!empty($result)){
//         		message('删除成功');
//         	}
//         }

//         if($operation == 'search'){
//         	$found = $_GPC['found'];
// 			$department_id = $_GPC['departmentid'];
			
// 			if($department_id == 1){
// 				$question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE( fl.id=wt.category_id and bm.id=fl.department_id and fl.category='{$found}') ");

// 			}else{
// 				$question = pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_qx')." as qx  WHERE( fl.id=wt.category_id and bm.id=fl.department_id and bm.id=qx.department_id and bm.id='{$department_id}' and fl.category='{$found}') ");
// 			}

//         }


// 		}

                                                           
	//	include $this->template('question');
	//}

	// public function doWebPower(){        //权限页面
		// global $_W,$_GPC;
		// require 'fans.web.php';

		// if (!empty($member['xh'])) {
		// 	$xuehao = $member['xh'];
		// }else{
		// 	$xuehao = $member['gh'];
		// }
		// $qx = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id = '{$xuehao}' ");

		// if ($qx > 0) {
		// 	$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
		// 	$department_id = pdo_fetch("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id = '{$xuehao}' ");
		// 	if($department_id['department_id'] == 1){                             //权益部  超级管理员权限
		// 		if($operation == 'display'){
		// 	    $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id ");
  //               $total = count($power);  
  //               $pageindex = max($_GPC['page'], 1 );  
  //               $pagesize = 10;  
  //               $pager = pagination($total, $pageindex, $pagesize);  
  //               $p = ($pageindex-1) * 10;  
  //               $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id LIMIT " . $p . "," . $pagesize);  
      

		//       }

		// 	}else{
		// 		if($operation == 'display'){                                            //其它部门权限  管理员权限
		// 	    $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id and bm.id='{$department_id['department_id']}' ");
		// 	    $total = count($power);  
  //               $pageindex = max($_GPC['page'], 1 );  
  //               $pagesize = 10;  
  //               $pager = pagination($total, $pageindex, $pagesize);  
  //               $p = ($pageindex-1) * 10;  
  //               $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id and bm.id='{$department_id['department_id']}' LIMIT " . $p . "," . $pagesize);  

		//       }

		// 	}

				
		// if($operation == 'add'){
		// 	$department = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_bm')."  ");

			
		//   if($_W['ispost']){
		// 	$data = array(
		// 		'openid' => '2',
		// 		'department_id' =>  $_GPC['department_id'],
		// 		'name' => $_GPC['name'],
		// 		'student_id' => $_GPC['student_id'],
		// 		'collegename' => $_GPC['collegename'],
		// 		'classname' => $_GPC['classname'],
		// 		'date'=>date("Y-m-d H:i:s")
		// 	);
		// 	$result = pdo_insert('zh_qyfk_qx',$data);
		// 	if(!empty($result)){
		// 		message('添加成功！');
		// 	}
		// 	else{
		// 		message('添加失败！');
		// 	}
		// }
	 // }


		// if($operation == 'change'){			
		// 	$change = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id and qx.id='{$_GPC['qx_id']}' ");

		// 	$id = $_GPC['qx_id'];
		// 	load()->func('tpl');
		// 	if(checksubmit('submit')){ 
		// 		$data = array(
		// 			'openid' => '2',
		// 		    'department_id' =>   $_GPC['department_id'],
		// 		    'name' => $_GPC['name'],
		// 		    'student_id' => $_GPC['student_id'],
		// 		    'collegename' => $_GPC['collegename'],
		// 		    'classname' => $_GPC['classname'],
		// 		    'date'=>date("Y-m-d H:i:s")
		// 		);
		// 		if(!empty($id) && $id>0){
		// 			$result = pdo_update('zh_qyfk_qx',$data,array('id'=>$id));
		// 			if(!empty($result)){
		// 				message('更新成功');
		// 			}
		// 			else{
		// 				message('更新失败');
		// 			}

		// 			}
		// 	}

		// }


		// if($operation == 'del'){
		// 	$result = pdo_delete('zh_qyfk_qx',array('id' => $_GPC['qx_id']));
		// 	if(!empty($result)){
		// 		message('删除成功');
		// 	}
		// }

		// if($operation == 'search'){
  //       	$found = $_GPC['found'];
		// 	$department_id = $_GPC['departmentid'];
			

		// 	if($department_id == 1){
				
		// 	    $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id and qx.name='{$found}' ");
			
				
		// 	}else{
				
		// 	    $power = pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE (qx.department_id=bm.id and bm.id='{$department_id}' and qx.name ='{$found}') or (qx.department_id=bm.id and bm.id='{$department_id}' and qx.student_id ='{$found}') ");
			
  //       }
        
  //   }


		// }

	
	// 	include $this->template('power');
	// }

	
		

// public function doWebXxdown(){   
	// global $_W,$_GPC;
	// $department_id = $_GPC['department_id'];
	// if($department_id == 1){
	// 	$bmlist=pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx join ".tablename('zh_qyfk_fl')." AS fl on xx.category_id=fl.id ");

	// }else{
	// 	$bmlist=pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_bm')." as bm where xx.category_id=fl.id and fl.department_id=bm.id and bm.id='{$department_id}' ");
	// }
	
	// $filename='反馈列表';
	
	// header("Content-type:application/octet-stream");
 //    header("Accept-Ranges:bytes");
 //    header("Content-type:application/vnd.ms-excel");  
 //    header("Content-Disposition:attachment;filename=".$filename.".xls");
 //     header("Pragma: no-cache");
 //     header("Expires: 0");
    
	// load()->func('file'); 
	// 	header("Content-Type:text/html;charset=utf-8"); 
	// 	require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel.php';
	// 	require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/IOFactory.php';
	// 	require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/Reader/Excel5.php';
	// 	error_reporting(E_ALL);  
	// 	ini_set('display_errors', TRUE);  
	// 	ini_set('display_startup_errors', TRUE);  
	// 	$excel = new PHPExcel();
	// 	//Excel表格式,这里写了12列  
	// 	$letter = array('A','B','C','D','E','F','G','H','I','J','K','L'); 
	// 	//表头数组  
	// 	$tableheader = array('id','反馈类别','备注','反馈者姓名','反馈者学号','反馈者学院','反馈者班级','反馈时间'); 
	// 	//填充表头信息  
	// 	for($i = 0;$i < count($tableheader);$i++) {  
	// 		$excel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");  
	// 	}
	// 	//填充表格信息
	// 	for ($i = 2;$i <= count($bmlist) + 1;$i++) { 
	// 			$j=$i-2; 
	// 			$excel->getActiveSheet()->setCellValue("$letter[0]$i",$bmlist[$j]['id']);
	// 			$excel->getActiveSheet()->setCellValue("$letter[1]$i",$bmlist[$j]['category']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[2]$i",$bmlist[$j]['remarks']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[3]$i",$bmlist[$j]['f_name']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[4]$i",$bmlist[$j]['f_studentid']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[5]$i",$bmlist[$j]['f_collegename']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[6]$i",$bmlist[$j]['f_classname']); 
	// 			$excel->getActiveSheet()->setCellValue("$letter[7]$i",$bmlist[$j]['date']);		   
				 
	// 	}   
	// 	$excel->getActiveSheet()->setTitle('反馈表');//重命名表  
	// 	$excel->getProperties()->setCreator("反馈表");
	// 	$excel->getProperties()->setTitle("Office 2007 hyqd");
	// 	$excel->setActiveSheetIndex(0); //设置sheet的起始位置
	// 	//创建Excel输入对象   
	// 	$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');  
		
		
	//  ob_end_clean();
 //     ob_start();
 //     header('Content-Type: application/vnd.ms-excel');
 //     header("Content-Disposition: attachment;filename=".$filename.".xlsx");
 //     header('Cache-Control: max-age=0'); 
 //     $objWriter->save('php://output'); //文件通过浏览器下载 
	
//}

// public function doWebQuestiondown(){   
// 	global $_W,$_GPC;
// 	$department_id = $_GPC['department_id'];
// 	if($department_id == 1){
// 		$bmlist=pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE( fl.id=wt.category_id and bm.id=fl.department_id) ");
// 	}else{
// 		$bmlist=pdo_fetchall("SELECT wt.id,wt.question,fl.category,bm.department,wt.date FROM ".tablename('zh_qyfk_wt')." as wt , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_bm')." as bm  WHERE( fl.id=wt.category_id and bm.id=fl.department_id and bm.id='{$department_id}') ");
// 	}
	
// 	$filename='问题选项表';
	
// 	header("Content-type:application/octet-stream");
//     header("Accept-Ranges:bytes");
//     header("Content-type:application/vnd.ms-excel");  
//     header("Content-Disposition:attachment;filename=".$filename.".xls");
//      header("Pragma: no-cache");
//      header("Expires: 0");
    
// 	load()->func('file'); 
// 		header("Content-Type:text/html;charset=utf-8"); 
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel.php';
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/IOFactory.php';
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/Reader/Excel5.php';
// 		error_reporting(E_ALL);  
// 		ini_set('display_errors', TRUE);  
// 		ini_set('display_startup_errors', TRUE);  
// 		$excel = new PHPExcel();
// 		//Excel表格式,这里写了12列  
// 		$letter = array('A','B','C','D','E','F','G','H','I','J','K','L'); 
// 		//表头数组  
// 		$tableheader = array('id','所属部门','类别','问题选项','更新时间'); 
// 		//填充表头信息  
// 		for($i = 0;$i < count($tableheader);$i++) {  
// 			$excel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");  
// 		}
// 		//填充表格信息
// 		for ($i = 2;$i <= count($bmlist) + 1;$i++) { 
// 				$j=$i-2; 
// 				$excel->getActiveSheet()->setCellValue("$letter[0]$i",$bmlist[$j]['id']);
// 				$excel->getActiveSheet()->setCellValue("$letter[1]$i",$bmlist[$j]['department']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[2]$i",$bmlist[$j]['category']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[3]$i",$bmlist[$j]['question']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[4]$i",$bmlist[$j]['date']); 
					   				 
// 		}   
// 		$excel->getActiveSheet()->setTitle('问题选项表');//重命名表  
// 		$excel->getProperties()->setCreator("问题选项表");
// 		$excel->getProperties()->setTitle("Office 2007 hyqd");
// 		$excel->setActiveSheetIndex(0); //设置sheet的起始位置
// 		//创建Excel输入对象   
// 		$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');  
		
		
// 	 ob_end_clean();
//      ob_start();
//      header('Content-Type: application/vnd.ms-excel');
//      header("Content-Disposition: attachment;filename=".$filename.".xlsx");
//      header('Cache-Control: max-age=0'); 
//      $objWriter->save('php://output'); //文件通过浏览器下载 
	
// }

// public function doWebPowerdown(){   
// 	global $_W,$_GPC;
// 	$department_id = $_GPC['department_id'];
// 	if($department_id == 1){
// 		$bmlist=pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department,qx.date FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id ");
// 	}else{
// 		$bmlist=pdo_fetchall("SELECT qx.id,qx.openid,qx.name,qx.student_id,qx.collegename,qx.classname,bm.department,qx.date FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm WHERE qx.department_id=bm.id and bm.id='{$department_id}' ");
// 	}
	
// 	$filename='权限表';
	
// 	header("Content-type:application/octet-stream");
//     header("Accept-Ranges:bytes");
//     header("Content-type:application/vnd.ms-excel");  
//     header("Content-Disposition:attachment;filename=".$filename.".xls");
//      header("Pragma: no-cache");
//      header("Expires: 0");
    
// 	load()->func('file'); 
// 		header("Content-Type:text/html;charset=utf-8"); 
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel.php';
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/IOFactory.php';
// 		require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/Reader/Excel5.php';
// 		error_reporting(E_ALL);  
// 		ini_set('display_errors', TRUE);  
// 		ini_set('display_startup_errors', TRUE);  
// 		$excel = new PHPExcel();
// 		//Excel表格式,这里写了12列  
// 		$letter = array('A','B','C','D','E','F','G','H','I','J','K','L'); 
// 		//表头数组  
// 		$tableheader = array('id','所属部门','审核人姓名','学号/工号','学院','班级','时间'); 
// 		//填充表头信息  
// 		for($i = 0;$i < count($tableheader);$i++) {  
// 			$excel->getActiveSheet()->setCellValue("$letter[$i]1","$tableheader[$i]");  
// 		}
// 		//填充表格信息
// 		for ($i = 2;$i <= count($bmlist) + 1;$i++) { 
// 				$j=$i-2; 
// 				$excel->getActiveSheet()->setCellValue("$letter[0]$i",$bmlist[$j]['id']);
// 				$excel->getActiveSheet()->setCellValue("$letter[1]$i",$bmlist[$j]['department']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[2]$i",$bmlist[$j]['name']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[3]$i",$bmlist[$j]['student_id']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[4]$i",$bmlist[$j]['collegename']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[5]$i",$bmlist[$j]['classname']); 
// 				$excel->getActiveSheet()->setCellValue("$letter[6]$i",$bmlist[$j]['date']); 				   				 
// 		}   
// 		$excel->getActiveSheet()->setTitle('权限表');//重命名表  
// 		$excel->getProperties()->setCreator("权限表");
// 		$excel->getProperties()->setTitle("Office 2007 hyqd");
// 		$excel->setActiveSheetIndex(0); //设置sheet的起始位置
// 		//创建Excel输入对象   
// 		$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');  
		
		
// 	 ob_end_clean();
//      ob_start();
//      header('Content-Type: application/vnd.ms-excel');
//      header("Content-Disposition: attachment;filename=".$filename.".xlsx");
//      header('Cache-Control: max-age=0'); 
//      $objWriter->save('php://output'); //文件通过浏览器下载 
	
// }


 	public function doMobileIndex() {
// 		global $_W,$_GPC;
// 		require 'fans.mobile.php'; 

// 		 $category = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_fl')." ");


// 		// $bmlist=pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_bm')." where id!= '1'  ");

// 		// foreach($bmlist as $key=>$bm){
// 		// 	$bmlist[$key]['child'] = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_fl')." where department_id={$bm['id']}");
// 		// }
		 
								
// 			//echo json_encode($json);
			
		

 		include $this->template('index');		
 	}

// 	public function doMobileFeedback(){
// 		global $_W,$_GPC;
// 		require 'fans.mobile.php';
// 		$question = pdo_fetchall("SELECT fl.id,wt.question FROM ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_wt')." as wt  where fl.id=wt.category_id and fl.department_id='{$_GPC['id']}' ");

// 			if($_W['ispost']){
// 			load()->func('file');
// 			$upload_dir="zh_qyfk/" . $_W['uniacid'] . "/";
// 			$upload_path = ATTACHMENT_ROOT . $upload_dir; 
// 			if (!file_exists($upload_path)) {
// 				@mkdirs($upload_path);
// 			}
// 			if ($_FILES) {
// 				foreach ($_FILES as $key => $upfile) {
// 					$error = $upfile['error'];
// 					$name = $upfile['name'];
// 					$type = $upfile['type'];
// 					$size = $upfile['size'];
// 					$tmp_name = $upfile['tmp_name'];
					
// 					if (intval($error) == 0) {  
// 						if (!is_uploaded_file($tmp_name)) {
// 							message('上传文件错误' . $_FILES["file"]["error"], referer(), 'error');
// 						}
// 						if ($size > 5 * 1024 * 1024) {
// 							message('上传文件过大' . $_FILES["file"]["error"], referer(), 'error');
// 						} 
// 						$uptypes = array('image/jpg', 'image/png', 'image/jpeg');
// 						if (!in_array($type, $uptypes)) {
// 							message('上传文件类型不符：' . $type, referer(), 'error');
// 						} 
// 						$source_filename =  date("YmdHis") . mt_rand(10, 99) . '.jpg';
// 						$target_filename =  date("YmdHis") . mt_rand(10, 99) . '.thumb.jpg'; 
// 						if (!move_uploaded_file($tmp_name, $upload_path . $source_filename)) {
// 							message('移动文件失败，请检查服务器权限', referer(), 'error');
// 						}
// 						$srcfile = $upload_path . $source_filename; 
// 						$desfile = $upload_path . $target_filename;
// 						$imginfo = getimagesize($srcfile);
// 						$imgtype = image_type_to_extension($imginfo[2], false);
// 						$fun = "imagecreatefrom" . $imgtype; 
// 						$image = $fun($srcfile);
// 						$color = imagecolorallocatealpha($image, 255, 0, 0, 50);
// 						imagejpeg($image, $srcfile);
// 						$avatarsize =  600;
// 						$ret = file_image_thumb($srcfile, $desfile, $avatarsize);
// 						if(!empty($ret)){
// 							$entry=array('url'=> $upload_dir . $target_filename); 
// 							$imgs[] = $entry;
// 						}
// 						unlink($srcfile);
// 					}	 
// 				}
// 			}  
// 			$data=array(
// 				'category_id'=>$_GPC['category_id'],
// 				'remarks'=>$_GPC['remarks'],
// 				'f_name'=>'王五',
// 				'f_studentid'=>'20161008777',
// 				'f_collegename'=>'信息科学与技术学院', 
// 				'f_classname'=>'电信1班',
// 				'studentid'=>'1111',
// 				'date'=>date("Y-m-d H:i:s"),
// 				'status'=>'未审核'

// 			);
// 			pdo_insert('zh_qyfk_xx',$data); 
// 			$id = pdo_insertid();
// 			if($id>0){	
// 				if (!empty($imgs)) {
// 					foreach ($imgs as & $r) {
// 						$r['f_id'] = $id;
// 						pdo_insert('zh_qyfk_upfile', $r);
// 					}
// 				}
// 				message('反馈成功', $this->createMobileUrl('index'), 'success');
// 			}else{
// 				message('反馈失败请联系管理员', $this->createMobileUrl('feedback', array( 'id' => $_W['uniacid'])), 'error');
// 			}
// 		}


// 		include $this->template('feedback');
// 	}

// 	public function doMobileMylist(){
// 		global $_W,$_GPC;
// 		require 'fans.mobile.php';


// 		include $this->template('mylist');
// 	}
	

// 	public function doMobileGetchildcate() {
// 	    global $_W,$_GPC;
	
// 		$result = pdo_fetchall("SELECT * FROM ".tablename('zh_qyfk_wt')." as wt WHERE wt.category_id='{$_GPC['id']}' ");
		
// 		echo json_encode($result); 
// }


	//后台首页
 public function doMobileAdmin() {
 		global $_W,$_GPC;
		require 'fans.mobile.php';
		$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
		$department_id = pdo_fetchall("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id='".$member['xh']."' ");
		foreach ($department_id as $key => $value) {
	          if($value['department_id']==1){
		          $qx_id=1;
			 }
	         $qx_id[]=$value['department_id'];
		  }
		
		//   if(empty($qx_id)){
		// 		$qx_id=" and 1=-1";
		// 	}elseif($qx_id!=='1'){
		// 		$qx_id=substing(explode (',',$qx_id),-1);
		// 		$qx_id="and bm.id in(".$qx_id.")";
		// 	}else{
		// 		$qx_id = 1 ;
		// 	}
		// 	echo "$qx_id";die;
       if($qx_id == 1 ){                                                                                  //权益部  超级管理员权限
		   if($operation == 'display'){
			$list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl where xx.category_id=fl.id ");
			foreach ($list as $k => $v) {
			$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
			$list[$k]['url']=$url['url'];
			}
		}

		
		if($operation == 'admin_change'){
			$c_result = pdo_fetch("SELECT xx.remarks,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.status,xx.date,fl.category FROM ".tablename('zh_qyfk_xx')." as xx , ".tablename('zh_qyfk_fl')." as fl where xx.category_id=fl.id and xx.id={$_GPC['x_id']} ");		
	   }

	   }else{                                                                                          //其他部门权限  管理员权限

		if($operation == 'display'){
			$list = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl , ".tablename('zh_qyfk_bm')." as bm where xx.category_id=fl.id and bm.id=fl.department_id and uniacid='".$_W['uniacid']."'and bm.id='".$qx_id[0]."' ");
			foreach ($list as $k => $v) {
			$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
			$list[$k]['url']=$url['url'];
			}
		}

		
		if($operation == 'admin_change'){
			$c_result = pdo_fetch("SELECT xx.remarks,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.status,xx.date,fl.category FROM ".tablename('zh_qyfk_xx')." as xx , ".tablename('zh_qyfk_fl')." as fl where xx.category_id=fl.id and xx.id={$_GPC['x_id']} ");		
	   }

	   }

		

		
		include $this->template('admin');

}

//后台首页修改功能
public function doMobileAdmin_change(){
	global $_W,$_GPC;
	$data = array(
		'category' => $_GPC['category'],
		'remarks' => $_GPC['remarks'],
		'f_name' => $_GPC['f_name'],
		'f_studentid' => $_GPC['f_studentid'],
		'f_collegename' => $_GPC['f_collegename'],
		'f_classname' => $_GPC['f_classname'],
		'date' => $_GPC['date'],
		'status' => $_GPC['status']

	);
	if(!empty($_GPC['f_name'])){
		$json=array('status'=>'1','message'=>'有值');
		echo json_encode($json);

	}
	else{
		$json=array('message'=>'无值');
		echo json_encode($json);
	}

}



//后台首页删除功能
public function doMobileAdmin_del(){
	global $_W,$_GPC;
		$id = $_GPC['id'];
		$result = pdo_delete('zh_qyfk_xx', array('id' => $id));
		if(!empty($id)){
			$json = array('status' => '1','message' => '删除成功');
			echo json_encode($json);
		}else{
			$json = array('message' => '删除失败');
			echo json_encode($json);
		}
}


//后台首页搜索功能
public function doMobileAdmin_search(){
	global $_W,$_GPC;

	    $search=$_GPC['search'];
		$sql = pdo_fetchall("SELECT fl.category,xx.id,xx.remarks,xx.img,xx.f_name,xx.f_studentid,xx.f_collegename,xx.f_classname,xx.status,xx.date FROM ".tablename('zh_qyfk_xx')." AS xx , ".tablename('zh_qyfk_fl')." AS fl WHERE xx.category_id=fl.id and f_name LIKE :f_name) ");

		$params = array();
		// $params[':uniacid'] = $_W['uniacid'];
		$params[':f_name'] = "%{$search}%";
		$list = pdo_fetchall($sql, $params);
		foreach ($list as $k => $v) {
			$url = pdo_fetch("SELECT url FROM ".tablename('zh_qyfk_upfile')." WHERE f_id={$v['id']}"); 
			$list[$k]['url']=$url['url'];
		}
		if(!empty($list)){
			$json = array('status' => '1','message' => '查询成功', 'data' => $list);
			echo json_encode($json);
		}else{
			$json = array('message' => '查询失败');
			echo json_encode($json);
		}

}

//问题模块
public function doMobileAdmin_manage(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
	$department_id = pdo_fetchall("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id='".$member['xh']."' ");
	foreach ($department_id as $key => $value) {
		  if($value['department_id']==1){
			  $qx_id=1;
		 }
		 $qx_id[]=$value['department_id'];
	  }

	  	
	if($qx_id == 1){
		if($operation == 'display'){
			$list = pdo_fetchall("SELECT wt.id,wt.question,wt.date,fl.category,bm.department,bm.uniacid FROM ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_wt')." as wt where bm.id=fl.department_id and fl.id=wt.category_id and uniacid='".$_W['uniacid']."' ");
		}

		if($operation == 'manage_change'){
			$question = pdo_fetchall("SELECT bm.department,fl.category,wt.question,wt.id FROM ".tablename('zh_qyfk_bm')." as bm , ".tablename('zh_qyfk_fl')." as fl , ".tablename('zh_qyfk_wt')." as wt where bm.id=fl.department_id and fl.id=wt.category_id and uniacid='".$_W['uniacid']."' ");

			$bm = pdo_fetchall("SELECT id,department FROM ".tablename('zh_qyfk_bm')."  ");
			$wt_id = $_GPC['wt_id'];
		    $wt = pdo_fetch("SELECT question FROM ".tablename('zh_qyfk_wt')." as wt where wt.id= '".$_GPC['wt_id']."' ");
		}

		if($operation == 'manage_add'){
			$bm = pdo_fetchall("SELECT id,department FROM ".tablename('zh_qyfk_bm')."  ");
		}
		
		
	}else{
		
	}
	
	include $this->template('admin_manage');
}

//问题模块联动
public function doMobileadmin_manage_add(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	
	$fl = pdo_fetchall("SELECT id,category FROM ".tablename('zh_qyfk_fl')." where department_id='".$_GPC['d_id']."' ");
	if(!empty($fl)){
		$json = array('status'=>'1','message'=>'成功','data'=>$fl );
		echo json_encode($json);
	}else{
		$json = array('message'=>'失败');
		echo json_encode($json);
	}

}

public function doMobileAdmin_manage_ad(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$data = array(
		'category_id' => $_GPC['category'],
		'question' => $_GPC['question'],
		'date' => date('Y-m-d H:i:s')
	);
	$result = pdo_insert('zh_qyfk_wt',$data);
	if(!empty($result)){
		$json = array('status'=>'1','message'=>'添加成功' );
		echo json_encode($json);
	}else{
		$json = array('message'=>'添加失败');
		echo json_encode($json);
	}

}


//问题模块  修改操作
public function doMobileAdmin_manage_change(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$data = array(
		'category_id' => $_GPC['category'],
		'question' => $_GPC['question'],
		'date' => date('Y-m-d H:i:s')
	);

	$result = pdo_update('zh_qyfk_wt',$data,array('id' => $_GPC['wt_id']));
	if(!empty($result)){
		$json = array('status'=>'1','message'=>'修改成功' );
		echo json_encode($json);
	}else{
		$json = array('message'=>'修改失败');
		echo json_encode($json);
	}


}

public function doMobileadmin_manage_ch(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	
	$fl = pdo_fetchall("SELECT id,category FROM ".tablename('zh_qyfk_fl')." where department_id='".$_GPC['de_id']."' ");
	if(!empty($fl)){
		$json = array('status'=>'1','message'=>'成功','data'=>$fl );
		echo json_encode($json);
	}else{
		$json = array('message'=>'失败');
		echo json_encode($json);
	}

}


//问题模块 删除操作
public function doMobileAdmin_manage_del(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$result = pdo_delete('zh_qyfk_wt',array('id' => $_GPC['id']));
	if(!empty($result)){
		$json = array('status' => '1','message' => '删除成功');
		echo json_encode($json);
	}else{
		$json = array('message' => '删除失败');
		echo json_encode($json);
	}

}


//权限模块
public function doMobileAdmin_power(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
	$department_id = pdo_fetchall("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id='".$member['xh']."' ");
	foreach ($department_id as $key => $value) {
		  if($value['department_id']==1){
			  $qx_id=1;
		 }
		 $qx_id[]=$value['department_id'];
	  }	
	if($qx_id == 1){
		if($operation == 'display'){
			$list = pdo_fetchall("SELECT bm.department,qx.id,qx.name,qx.student_id,qx.collegename,qx.classname,qx.date FROM ".tablename('zh_qyfk_qx')." as qx , ".tablename('zh_qyfk_bm')." as bm where bm.id=qx.department_id ");
		}

		if($operation == 'add'){
			$bm = pdo_fetchall("SELECT id,department FROM ".tablename('zh_qyfk_bm')." ");
			
			
		}
		
		
	}else{
		
	}
	include $this->template('admin_power');

}

public function doMobileAdmin_power_add(){
	global $_W,$_GPC;
	require 'fans.mobile.php';
	$studentid = $_GPC['student_id'];
	//$studentbaseinfo = pdo_fetch("SELECT * FROM ".tablename('zh_base_stu')." where xh='".$studentid."' and uniacid='".$_W['uniacid']."'");
	$studentbaseinfo = pdo_fetch("SELECT * FROM ".tablename('zh_base_stu')." where xh='20153333' and uniacid='".$_W['uniacid']."'");
	if(empty($studentbaseinfo)){	
		$studentfans = pdo_fetch("SELECT * FROM ".tablename('mc_mapping_fans')." where studentid='".$student_id."' and uniacid='".$_W['uniacid']."'");  //通过openid和uniacid来																												//如果查找不到
		$studentinfo = pdo_fetch("SELECT * FROM ".tablename('mc_members')." where uid='".$studentfans['uid']."' and uniacid='".$_W['uniacid']."'");  //通过fans表中的uid来查找用户数据信息
		$student['xh'] = $studentinfo['studentid'];  
		$student['xm'] = $studentinfo['realname'];
		$student['xy'] = $studentinfo['classname'];
		$student['bj'] = '';

	}else{

		$student['xm'] = $studentbaseinfo['xm']; 
		$student['xh'] = $studentbaseinfo['xh'];
		$student['xy'] = $studentbaseinfo['xy']; 
		$student['bj'] = $studentbaseinfo['bj'];
		
	}
	$da = array(
		'department_id' => $_GPC['department'],
		'name' => $student['xm'],
		'student_id' => $_GPC['student_id'],
		'collegename' => $student['xy'],
		'classname' => $student['bj'],
		'date' => date('Y-m-d H:i:s')
	);
	
	$re = pdo_insert('zh_qyfk_qx',$da);
	if(!empty($re)){
		$json = array('status'=>'1','message'=>'添加成功' );
		echo json_encode($json);
	}else{
		$json = array('message'=>'添加失败');
		echo json_encode($json);
	}

}





}


// $department_id = pdo_fetchall("SELECT department_id FROM ".tablename('zh_qyfk_qx')." as qx where qx.student_id='".$member['xh']."' ");
// 	foreach ($department_id as $key => $value) {
// 		  if($value['department_id']==1){
// 			  $qx_id=1;
// 		 }
// 		 $qx_id[]=$value['department_id'];
// 	  }
// 	if($qx_id == 1){
		
// 	}else{
		
// 	}


//BUG
//1.问题的修改和添加权限
//2.权限页面的添加和修改